﻿using System;
using System.Data;
using System.Windows.Forms;
using ProrabHelp.Library;
using DataGridViewAutoFilter;

namespace ProrabHelp.UI
{
    public partial class Remains : UserControl
    {
        ServerObject mServerObject = null;

        public Remains()
        {
            InitializeComponent();
            mServerObject = new ServerObject();
        }      

        private void closeButton_Click(object sender, EventArgs e)
        {
            mServerObject.CloseThisTab(this);
        }

        private void Remains_Load(object sender, EventArgs e)
        {
            FillRemainsGridView();
        }

        private void FillRemainsGridView()
        {
            BindingSource bindigSource = new BindingSource(mServerObject.GetRemainsList(), null);
            remainsGridView.DataSource = bindigSource;

            if (remainsGridView.DataSource != null)
            {
                foreach (DataGridViewColumn col in remainsGridView.Columns)
                {
                    col.HeaderCell = new DataGridViewAutoFilterColumnHeaderCell(col.HeaderCell);
                }

                remainsGridView.AutoResizeColumns();
            }
        }

        private void incomeProductButton_Click(object sender, EventArgs e)
        {
            IncomProductInputForm incompRod = new IncomProductInputForm();
            incompRod.ShowDialog();
        }

        



    }
}
